ISubscribe<'TDataEvent>Type

PackageFCQRS

Specification

Kind
Type
Members
4
Examples
0
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe

Summary

NameSignatureSynopsis
Subscribethis.SubscribeSubscribes to events matching a specific correlation ID and an additional filter.
Subscribethis.SubscribeSubscribes to events matching a specific correlation ID.
Subscribethis.SubscribeSubscribes to events using a filter.
Subscribethis.SubscribeSubscribes to all events and invokes the specified callback for each event.

Subscribe

this.Subscribe
Member
Subscribes to events matching a specific correlation ID and an additional filter.

Parameters

NameTypeDescription
cidCIDThe correlation ID to match.
filter'TDataEvent -> boolAdditional predicate to filter events after CID matching.
takeintMaximum number of events to process.
callback'TDataEvent -> unit
cancellationTokenCancellationToken

Returns

IAwaitableDisposable

Subscribe

this.Subscribe
Member
Subscribes to events matching a specific correlation ID.

Parameters

NameTypeDescription
cidCIDThe correlation ID to match.
takeintMaximum number of events to process.
callback'TDataEvent -> unit
cancellationTokenCancellationToken

Returns

IAwaitableDisposable

Subscribe

this.Subscribe
Member
Subscribes to events using a filter. Only events for which the predicate returns true are processed, and the callback is invoked for each matching event up to a specified count. Registration is complete when this method returns. The Task succeeds only after that count is reached; cancellation or disposal before then cancels it.

Parameters

NameTypeDescription
filter'TDataEvent -> bool Predicate function to determine if an event should be processed, e.g. fun event -> event.CorrelationId = targetId.
takeintMaximum number of events to process.
callback'TDataEvent -> unit
cancellationTokenCancellationToken

Returns

IAwaitableDisposable

Verification Examples

// Typical usage: subscribe for a filtered event by matching on CorrelationId,
// process only one event, and omit the callback and cancellation token.
async {
    let targetId = some-correlation-id
    // Here, take is set to 1 and no callback or cancellation token is provided.
    let! subscription = query.Subscribe((fun event -> event.CorrelationId = targetId), 1)
    // Use the asynchronous subscription as needed.
} |> Async.Start

Subscribe

this.Subscribe
Member
Subscribes to all events and invokes the specified callback for each event. Registration is complete when this method returns. Callbacks run in order on a separate worker; a full subscriber queue drops its oldest notification.

Parameters

NameTypeDescription
callback'TDataEvent -> unitFunction invoked for each event, e.g. printing or processing the event.
cancellationTokenCancellationToken

Returns

IDisposable

Verification Examples

// Example usage: subscribe to all events and write them to the console.
let subscription =
    query.Subscribe((fun event -> printfn "Received event: %A" event))

// Later, to cancel the subscription:
subscription.Dispose()